package achi.community.irla.beans;

import achi.community.irla.database.Crypto;
import achi.community.irla.database.DatabaseImpl;
import achi.community.irla.database.ModelBean;
import achi.community.irla.entities.Achievements;
import achi.community.irla.entities.Users;
import com.icesoft.faces.context.effects.Effect;
import com.icesoft.faces.context.effects.Highlight;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.Serializable;
import java.lang.String;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ResourceBundle;
import javax.ejb.EJB;
import javax.faces.application.FacesMessage;
import javax.faces.application.ViewHandler;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;
import javax.faces.component.UIComponent;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import javax.faces.event.FacesEvent;
import javax.faces.event.ValueChangeEvent;
import javax.faces.validator.ValidatorException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * RegControlBean: Validation for register.xhtml Adds the new Customer to DB and
 * ModelBean
 */
@ManagedBean
@RequestScoped
public class CompletedControlBean implements Serializable {

    private boolean owner = false;
    @ManagedProperty(value = "#{completedBackBean}")
    CompletedBackBean backBean;
    
    @ManagedProperty(value = "#{modelBean}")
    ModelBean modelBean;

    public ModelBean getModelBean() {
        return modelBean;
    }

    public void setModelBean(ModelBean modelBean) {
        this.modelBean = modelBean;
    }

    public CompletedBackBean getBackBean() {
        return backBean;
    }

    public void setBackBean(CompletedBackBean backBean) {
        this.backBean = backBean;
    }

    public boolean isOwner() {
        Users uOwner = modelBean.getUser();
        Users user = modelBean.getUser();
        System.out.println("Owner:"+uOwner+" user:"+user);
        if (uOwner.equals(user)) {
            owner = true;
        }
        return owner;
    }

    public void setOwner(boolean owner) {
        this.owner = owner;
    }
}
